package firstTry;

import java.awt.image.BufferedImage;

public class Cloud extends Sprite {

	final int SPEED = 20;
	
	public Cloud(BufferedImage[] i, double x, double y, long delay, GamePanel p) {
		super(i, x, y, delay, p);
		
		if((int)(Math.random()*2)>1){
			setHorizontalSpeed(-SPEED);
		}else{
			setHorizontalSpeed(SPEED);
		}
	}

	public void doLogic(long delta) {
		super.doLogic(delta);
		
		if(getHorizontalSpeed()>0 && getX()>parent.getWidth()){
			setX(-getWidth());
		}
		
		if(getHorizontalSpeed()<0 && (getX()+getWidth()<0)){
			setX(parent.getWidth()+getWidth());
		}
		
	}

	@Override
	public boolean collidedwith(Sprite s) {
		// TODO Auto-generated method stub
		return false;
	}
	
}
